package com.franklin.ideaplugin.easytesting.ui;

import com.franklin.ideaplugin.api.ui.IBaseComponent;
import com.franklin.ideaplugin.api.ui.ToolBarWindowForm;
import com.franklin.ideaplugin.api.utils.SwingUtils;

import javax.swing.*;
import java.awt.event.*;

public class TestDialog extends JDialog implements IBaseComponent {
    private JPanel contentPane;
    private JPanel mainPanel;

    private final ToolBarWindowForm toolBarWindowForm;

    public TestDialog(ToolBarWindowForm toolBarWindowForm) {
        this.toolBarWindowForm = toolBarWindowForm;
        setContentPane(contentPane);
        setBounds(100, 100, 800, 600);

        setModal(true);

        // call onCancel() when cross is clicked
        setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
        addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
                onCancel();
            }
        });
        mainPanel.setLayout(SwingUtils.createLayoutManager(1,1));
        this.addCell(mainPanel,this.toolBarWindowForm.getMainPanel(),0,0,Sizes.ExecuteMethodFormSize.MAIN_SIZE);
    }

    private void onOK() {
        // add your code here
        dispose();
    }

    private void onCancel() {
        // add your code here if necessary
        dispose();
    }

    @Override
    public JComponent getMainPanel() {
        return this.mainPanel;
    }
}
